package com.yutianran.springBoot.thread;

import java.util.concurrent.CountDownLatch;

public class Job implements Runnable {

    private CountDownLatch latch;
    private int task;
    private int time;

    public Job(CountDownLatch latch, int task, int time) {
        this.latch = latch;
        this.task = task;
        this.time = time;
    }

    public int getTask() {
        return task;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(String.format("完成任务 当前线程：%s 任务：%s", Thread.currentThread().getName(), task));
        latch.countDown();
    }
}
